package com.itheima.common;

import com.itheima.vo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author zhangpei
 * @ClassName ExceptionHandler
 * @date 2022/5/25/17:27
 */
@RestControllerAdvice(annotations = {RestController.class, Controller.class})
@Slf4j
public class AllExceptionHandler {

    @ExceptionHandler(MyException.class)
    public R<String> exceptionHandler(MyException ex){
        log.info("开始处理异常");
        return R.error(ex.getMessage(),1000);
    }
}
